import React from "react";
import Input from "../../components/Input";
import type { FieldBaseType } from "../../type";

export default function StringInput({
  field,
  isValid,
  onChange,
}: {
  field: FieldBaseType<string>;
  isValid: boolean;
  onChange: (v: string) => void;
}) {
  const { value, defaultValue, placeholder, prefix, suffix, meta, disabled } =
    field;

  return (
    <Input
      disabled={disabled}
      placeholder={placeholder}
      invalid={!isValid}
      value={value ?? defaultValue ?? ""}
      type="text"
      min={meta?.min}
      max={meta?.max}
      suffix={suffix}
      prefix={prefix}
      onChange={onChange}
    />
  );
}

// StringInput.whyDidYouRender = true;
